﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BLL;

public partial class CardCenter_CardBlanceSelect : System.Web.UI.Page
{
    ConsultationCardBalanceSelect bllBlance = new ConsultationCardBalanceSelect();
    WebUtility utility = new WebUtility();
    AccountsCharge bllAccount = new AccountsCharge();

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btn_Select_Click(object sender, ImageClickEventArgs e)
    {
        string cardNO = this.txt_CardNO.Text.Trim();
        string cardPwd = this.txt_CardPwd.Text.Trim();

        DataTable dtCardInfo = bllBlance.IsExistsCardNO(cardNO);
        if (dtCardInfo.Rows.Count == 0)
        {
            utility.AlertMsg("对不起，您输入的卡号不存在！");
            this.txt_CardNO.Text = string.Empty;
            this.txt_CardPwd.Text = string.Empty;
        }
        else
        {
            DataTable dtAccount = bllAccount.CheckCardInfo(cardNO, cardPwd);
            if (dtAccount.Rows.Count == 0)
            {
                utility.AlertMsg("卡号和密码输入错误，请重新输入！");
                this.txt_CardNO.Text = string.Empty;
                this.txt_CardPwd.Text = string.Empty;
            }
            else
            {
                string blance = (string)bllBlance.GetCardBalance(cardNO);
                this.txt_CardNO.Text = string.Empty;
                this.txt_CardPwd.Text = string.Empty;
                Response.Redirect("CardBlanceSelectResult.aspx?blance=" + blance);
            }
        }
    }
}
